//
//  YMNetwork.h
//  GuoAo
//
//  Created by y s on 2023/3/9.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

static NSString *const kBaseUrl = @"http://139.224.14.244:8080";
//脱兔url
static NSString *const KTuoToUrl = @"http://139.224.14.244:8888/api";

typedef void(^YSSuccessBlock)(id data);
typedef void(^YSFailureBlock)(NSError *error);

@interface YMNetwork : NSObject

+ (instancetype)shared;


/** get 请求 */
+ (void)getWithUrl:(NSString *)url
        parameters:(NSDictionary *)parameters
           success:(YSSuccessBlock)success
           failure:(YSFailureBlock)failure;

/** post 请求 */
+ (void)postWithUrl:(NSString *)url
         parameters:(id)parameters
            success:(YSSuccessBlock)success
            failure:(YSFailureBlock)failure;
/** PUT请求 */
+ (void)putWithUrl:(NSString *)url
        parameters:(NSDictionary *)parameters
           success:(YSSuccessBlock)success
           failure:(YSFailureBlock)failure;
/** Delete请求 */
+ (void)deleteWithUrl:(NSString *)url
           parameters:(NSDictionary *)parameters
              success:(YSSuccessBlock)success
              failure:(YSFailureBlock)failure;

/** 上传文件 */
+ (void)uploadWithUrl:(NSString *)url
             filePath:(NSString *)filePath
             fileName:(NSString *)fileName
                 name:(NSString *)name
             mimeType:(NSString *)mimeType
           parameters:(NSDictionary *)parameters
              success:(YSSuccessBlock)success
              failure:(YSFailureBlock)failure;
/** 上传data 文件 */
+ (void)uploadDataWithUrl:(NSString *)url
                 fileData:(NSData *)fileData
                 fileName:(NSString *)fileName
                     name:(NSString *)name
                 mimeType:(NSString *)mimeType
               parameters:(NSDictionary *)parameters
                  success:(YSSuccessBlock)success
                  failure:(YSFailureBlock)failure;
/** 下载文件 */
+ (void)downloadWithUrl:(NSString *)url
                success:(void(^)(NSURL *path))success
                failure:(YSFailureBlock)failure;

/** 拖兔接口请求是否成功 */
+ (BOOL)tuoTuSuccess:(NSString *)status;

@end

NS_ASSUME_NONNULL_END
